package com.yenlien.traceyun.business.service;

import com.yenlien.traceyun.business.service.rest.usercenter.AppRestService;
import com.yenlien.traceyun.common.utils.LoggerUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 * @author: bigwangy@sina.com
 * @create: 2020-03-10
 * @description:
 **/

@Service
public class AppService {
    @Autowired
    private AppRestService appRestService;

    @Value("${traceyun.app.id}")
    private String appId;

    @Value("${traceyun.app.name}")
    private String appName;

    @Value("${traceyun.app.type}")
    private String appType;

    @Value("${traceyun.app.code}")
    private String appCode;


    /**
     * 注册服务
     */
    public void register() {
        LoggerUtil.getLogger().info("begin register app");
        try {
            appRestService.register(appId, appName, appType, appCode);
        } catch (Exception e) {
            LoggerUtil.getLogger().info("appid:{} register finish,发生错误：{}", appId, e.getMessage());
            return;
        }
        LoggerUtil.getLogger().info("appid:{} register finish", appId);

    }
}
